﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FyAutoStartService.Models
{
    public class AppInfo
    {
        public string? Id { get; set; }

        /// <summary>
        /// 程序名
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 程序路径
        /// </summary>
        public string? Path { get; set; }

        /// <summary>
        /// 启动参数
        /// </summary>
        public string? Args { get; set; }

        /// <summary>
        /// 程序是否开机自启动，有的程序可能后期不需要自动重启了，但又不想删除，也许
        /// 以后还会需要自动启动，这时就可以把该项设置为false
        /// </summary>
        public bool? IsAutoStart { get; set; }

        /// <summary>
        /// 程序关闭后是否自动开启
        /// </summary>
        public bool? IsAutoRestart { get; set; } = true;

        /// <summary>
        /// 程序关闭后过多少时间自动启动
        /// </summary>
        public int? AutoRestartTime { get; set; } = 5;

        /// <summary>
        /// 程序当前是否正在运行
        /// </summary>
        public bool? IsRunning
        {
            get
            {
                bool res = false;
                if (Process != null)
                {
                    if (Process.HasExited == false)
                        res = true;
                }
                return res;
            }
        }

        /// <summary>
        /// 内部用，程序线程
        /// </summary>
        internal Process? Process { get; set; }

        /// <summary>
        /// 程序关闭时间
        /// </summary>
        internal DateTime? CloseTime { get; set; }
    }
}
